package edu.nctu.csie.jichang.database.model.connection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.List;

import edu.nctu.csie.jichang.database.model.builder.ISQLBuilder;
import edu.nctu.csie.jichang.database.model.cell.ColumnFullInfo;
import edu.nctu.csie.jichang.database.model.cell.ColumnInfo;
import edu.nctu.csie.jichang.database.model.cell.ColumnInfoValue;
import edu.nctu.csie.jichang.database.model.cell.NameMap;
import edu.nctu.csie.jichang.database.model.cell.RefTableMapping;
import edu.nctu.csie.jichang.database.model.cell.SchemaTable;

public interface IDBConnection {

	public Connection getConnection();
	
	public ISQLBuilder getBuilder();
	
	public List<String> getAllTables();
	
	public List<String> getInsertOrder();
	public String getInsertOrderString();
	
	public NameMap getReference(String pTableName);
	public NameMap getIndexs(String pTableName);
	public NameMap getPrimaryKeys(String pTableName);
	public NameMap getUniques(String pTableName);
	
	public List<String> getRefTable(String pTableName);
	public List<SchemaTable> getRefTable(SchemaTable pTable);
	public List<RefTableMapping> getRefTableMapping(SchemaTable pTable1,SchemaTable pTable2);
	
	public List<String> getReferenceColumn(String pTableName);
	public List<String> getIndexColumn(String pTableName);
	public List<String> getPrimaryKeyColumn(String pTableName);
	public List<String> getUniqueColumn(String pTableName);

	public ColumnInfo getColumnInfo(String pTableName,String pColumnName);
	
	public List<ColumnInfo> getColumnInfo(String pTableName);

	public ColumnFullInfo getColumnFullInfo(String pTableName,String pColumnName);
	
	public List<ColumnFullInfo> getColumnFullInfo(String pTableName);
	
	public Statement getStatement();
	
	public ResultSet getQueryResult(Statement pState,String pSQL);
	
	public void executeUpdate(Statement pState,String pSQL);
	
	public void executeUpdate(String pSQL);
	
	public void executeBatchUpdate(String pSQL);
	
	public ResultSet getTableData(Statement pState,String pTableName);
	
	public void close();
	
	public void close(ResultSet pRS);
	
	public void close(Statement pState);
	
	public void close(ResultSet pRS,Statement pState);
	
	public void setAutoCommit(boolean pCommit);
	
	public void commit();
	
	public void rollback();

	public boolean isHasTable(String pTableName);
	
	public boolean isHasRow(String pTableName,List<ColumnInfoValue> pValues);
	
	public boolean cleanAllTablesData();

	public boolean deleteByColumn(String pTableName,ColumnInfoValue pColumn);
	
	public void dropDatabase();
	
	public void dropAndCreateDatabase();
	
}